class RaiseMiddleware(object):
    def __init__(self,app,page_list):
        self.app=app
        self.page_list=page_list

    def __call__(self,environ,start_response):
        if environ['PATH_INFO'] in self.page_list:
            raise StandardError
        else:
            return self.app(environ,start_response)

from pickle import dumps
from webob import Request
from logging import getLogger
log=getLogger(__name__)

class LogRequestMiddleware(object):

    def __init__(self,app,page_list):
        self.app=app
        self.page_list=page_list

    def __call__(self,environ,start_response):
        if environ['PATH_INFO'] in self.page_list:
            req=Request(environ)
            for name in dir(req):
                if not name.startswith('__'):
                    log.info('%s : %s' % (name,getattr(req,name)))
            for key,value in environ.items():
                log.info('%s - %s' % (key,value))
        return self.app(environ,start_response)
        
class LogMethodMiddleware(object):

    def __init__(self,app):
        self.app=app

    def __call__(self,environ,start_response):
        log.info('%s : %s' % (environ['PATH_INFO'],Request(environ)))
        return self.app(environ,start_response)
